package com.demo.spring.autowird;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

public class Bean1 {
	
	private Bean2 bean2;
	
	@Autowired
	public void setBean2(Bean2 bean2) {
		System.out.println("@Autowired 生效：" + bean2);
		this.bean2 = bean2;
	}
	
	private Bean3 bean3;
	
	@Resource
	public void setBean3(Bean3 bean3) {
		System.out.println("@Resource 生效：" + bean3);
		this.bean3 = bean3;
	}
	
	private String home;
	
	@Autowired
	public void setHome(@Value("${JAVA_HOME}") String home) {
		System.out.println("@Value 生效：" + home);
		this.home = home;
	}
	
	@PostConstruct
	public void init() {
		System.out.println("@PostConstruct 生效");
	}

	@Override
	public String toString() {
		return "Bean1 [bean2=" + bean2 + ", bean3=" + bean3 + ", home=" + home + "]";
	}

}
